<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>默认行为</title>
    <style>
        body{
            height: 1000px;
        }
        a{
            display: block;
            margin: 130px auto;
            width: 100px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            color: #333333;
            text-decoration: none;
            background-color: red;
        }
    </style>
</head>
<body>
<a id="a1" href="">链接</a>
<!--<a id="a1" href="javascript: void 0">链接</a>-->
<!--<a id="" href="#">链接</a>-->
<!--href = "#" 锚点 (回到顶部)-->
<script>
    let a1 = document.getElementById("a1");
    a1.onclick = function (e) {
        e.preventDefault();
        e.preventDefault = function () {
            e.returnValue = false //IE兼容
        };
        console.log(e)
    }
</script>
</body>
</html>